package com.core.zyyz.pcmc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.core.zyyz.pcmc.domain.ValueSetValue;
import com.core.zyyz.pcmc.service.ValueSetValueService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.annotation.Log;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.enums.BusinessType;
import com.core.common.utils.poi.ExcelUtil;
import com.core.common.core.page.TableDataInfo;

/**
 * 值集值Controller
 *
 * @author core
 * @date 2024-10-24
 */
@RestController
@RequestMapping("/pcmc/valueSetValue")
public class ValueSetValueController extends BaseController
{
    @Autowired
    private ValueSetValueService valueSetValueService;

    /**
     * 查询值集值列表
     */
    @PreAuthorize("@ss.hasPermi('pcmc:valueSetValue:list')")
    @GetMapping("/list")
    public TableDataInfo list(ValueSetValue valueSetValue)
    {
        startPage();
        List<ValueSetValue> list = valueSetValueService.selectValueSetValueList(valueSetValue);
        return getDataTable(list);
    }

    /**
     * 导出值集值列表
     */
    @PreAuthorize("@ss.hasPermi('pcmc:valueSetValue:export')")
    @Log(title = "值集值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ValueSetValue valueSetValue)
    {
        List<ValueSetValue> list = valueSetValueService.selectValueSetValueList(valueSetValue);
        ExcelUtil<ValueSetValue> util = new ExcelUtil<ValueSetValue>(ValueSetValue.class);
        util.exportExcel(response, list, "值集值数据");
    }

    /**
     * 获取值集值详细信息
     */

    @PreAuthorize("@ss.hasPermi('pcmc:valueSetValue:queryKeys')")
    @PostMapping(value = "/queryKeys")
    public AjaxResult getInfo(@RequestBody ValueSetValue valueSetValue)
    {
        return success(valueSetValueService.selectValueSetValueByKeys(valueSetValue));
    }

    /**
     * 新增值集值
     */
    @PreAuthorize("@ss.hasPermi('pcmc:valueSetValue:add')")
    @Log(title = "值集值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ValueSetValue valueSetValue)
    {
        return toAjax(valueSetValueService.insertValueSetValue(valueSetValue));
    }

    /**
     * 修改值集值
     */
    @PreAuthorize("@ss.hasPermi('pcmc:valueSetValue:edit')")
    @Log(title = "值集值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ValueSetValue valueSetValue)
    {
        return toAjax(valueSetValueService.updateValueSetValue(valueSetValue));
    }


    /**
     * 删除值集值
     */
    @PreAuthorize("@ss.hasPermi('pcmc:valueSetValue:remove')")
    @Log(title = "值集值", businessType = BusinessType.DELETE)
    @DeleteMapping("/{valueCode}")
    public AjaxResult remove(@PathVariable String[] valueCode)
    {
        return toAjax(valueSetValueService.deleteValueSetValueByValueSetCodes(valueCode));
    }

    /**
     * 删除值集值
     */
    @PreAuthorize("@ss.hasPermi('pcmc:valueSetValue:oaPathRemove')")
    @Log(title = "值集值", businessType = BusinessType.DELETE)
    @DeleteMapping("/oaPath/{valueCode}")
    public AjaxResult oaPathRemove(@PathVariable String[] valueCode)
    {
        return toAjax(valueSetValueService.deleteOaPathValueSetValueByValueSetCodes(valueCode));
    }


}
